Skip to content

Thread statuses improvements#398

Open
arfio wants to merge 2 commits into
eclipse-tracecompass:masterfrom
arfio:thread-statuses-improvements
Open

Thread statuses improvements#398
arfio wants to merge 2 commits into
eclipse-tracecompass:masterfrom
arfio:thread-statuses-improvements

Conversation

@arfio
Copy link
Copy Markdown
Contributor

@arfio arfio commented May 6, 2026

What it does

  • Make callstack analysis with multiple callstacks for each thread work without having errors
  • Reverse the filter which was not implemented correctly, when the predicate is true, the element is kept.

How to test

Open a callstack analysis that have threads callstacks with a kernel trace alongside it. For example using eclipse-tracecompass-incubator/org.eclipse.tracecompass.incubator#265

Follow-ups

N/A

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Summary by CodeRabbit

  • Bug Fixes
    • Improved accuracy of thread-interval timestamp querying in kernel analysis; kernel-level states now surface the correct syscall label in flame charts.
  • Refactor
    • Flame chart handling updated to support multiple linked kernel entries per thread.
  • Tests
    • Tests adjusted to expect syscall labels and to enforce exact state counts before per-state comparisons.
  • Style
    • Annotation formatting cleaned up; event-stub behavior refined for instant events.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Tightened timestamp filtering in KernelThreadInformationProvider, refactored FlameChartDataProvider to group multiple linked kernel entry IDs per thread and build kernel states per linked entry, updated tests to expect syscall labeling and adjusted a stub's event handling; minor annotation formatting edits.

Changes

Thread Status Interval Filtering

Layer / File(s) Summary
Filtering Logic
analysis/org.eclipse.tracecompass.analysis.os.linux.core/.../KernelThreadInformationProvider.java
getStatusIntervalsForThreads now filters times to include only timestamps strictly inside the state system bounds (ss.getStartTime(), ss.getCurrentEndTime()), altering which timestamps are passed to ss.query2D(...).

Flame Chart Data Handling

Layer / File(s) Summary
Kernel State Grouping
analysis/org.eclipse.tracecompass.analysis.profiling.core/.../FlameChartDataProvider.java (lines 580–606)
getKernelStates groups TidInformation by thread ID into sets of linked kernel entry IDs, queries statuses once per thread, then iterates linked entry IDs to resolve entry IDs and build TimeGraphState objects stored per linked entry ID.
Annotation Formatting
analysis/org.eclipse.tracecompass.analysis.profiling.core/.../FlameChartDataProvider.java (lines 735, 766, 788–792, 801)
Whitespace/formatting adjustments and reflow of OutputElementStyle/Annotation construction; no functional change to annotation values.

Tests & Stub

Layer / File(s) Summary
Test expectations
analysis/.../FlameChartDataProviderTest.java (lines 255–265, 300–303, 437–440)
Updated expected kernel TimeGraphState label at time 12 to "openat" with LinuxStyle.SYSCALL; verifyStates now asserts equal list sizes before index-wise checks.
Stub event handling
analysis/.../KernelStateProviderStub.java (lines 60–74)
Ignore "instant_event" events; extract "op" into operationName with null check and only apply "op4"-specific transition when operationName equals "op4", otherwise use RUN/WAIT_CPU as before.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant FlameChart as FlameChartDataProvider
  participant SS as StateSystem
  participant Tests
  Client->>FlameChart: request kernel states for tid-list
  FlameChart->>FlameChart: group TidInformation by TID -> linkedEntryIds set
  FlameChart->>SS: query statuses for each TID once
  SS->>FlameChart: return intervals
  FlameChart->>FlameChart: iterate linkedEntryIds -> resolve entryId, build TimeGraphState per linked entry
  FlameChart->>Tests: provide states (with syscall labels/styles)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A filter flipped, a thread map grows,
Multiple kernels in a single row,
Tests tuned to names that now are shown,
Stubs guard instant events on their own,
Annotations tidy—code hops along.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "Thread statuses improvements" is vague and generic, using the non-descriptive term "improvements" without conveying the specific nature of the changes. Consider a more specific title that captures the main technical change, such as "Fix multiple callstack support with kernel trace analysis" or "Correct filter logic in thread status analysis".
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java`:
- Line 551: The filter predicate for currentTimes is incorrect: change the
boolean operator so it keeps times within the session window instead of almost
always allowing them; in the times.stream() filter that references
ss.getCurrentEndTime() and ss.getStartTime(), replace the OR condition with an
AND (so times satisfy time < ss.getCurrentEndTime() && time > ss.getStartTime(),
adjust inclusivity if needed) to ensure only timestamps inside the current time
window are collected before sorting and collecting into currentTimes.

In
`@analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented/FlameChartDataProvider.java`:
- Around line 583-585: The threadIdsToEntryIds collection currently uses
Collectors.toList(), which allows duplicate tid.fLinked values per thread and
leads to duplicate kernel states during the status-expansion that follows;
change the collector on the tids stream (the code that builds
threadIdsToEntryIds in FlameChartDataProvider) to collect unique linked IDs
instead (e.g., use Collectors.toCollection(LinkedHashSet::new) or
Collectors.toSet() so each tid.fLinked appears only once per thread) and update
any downstream code that expects a List (the expansion loop that iterates over
threadIdsToEntryIds entries) to iterate the resulting Set or convert it to a
List if ordering is required.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e64aa7c9-86b3-4b37-be29-a807f56940e3

📥 Commits

Reviewing files that changed from the base of the PR and between b5bdbd3 and bdd20cc.

📒 Files selected for processing (2)
  • analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented/FlameChartDataProvider.java

@arfio arfio force-pushed the thread-statuses-improvements branch from bdd20cc to 84539f9 Compare May 6, 2026 20:42
arfio added 2 commits May 7, 2026 16:06
…he same tid

Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
@arfio arfio force-pushed the thread-statuses-improvements branch from 84539f9 to 9a9e5c5 Compare May 7, 2026 20:07
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java (2)

29-30: 💤 Low value

Remove commented-out duplicate imports.

Lines 29 and 59 are commented-out versions of their immediately adjacent active imports — debug artifacts that add noise.

🧹 Proposed cleanup
-//import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 import org.eclipse.tracecompass.tmf.core.model.annotations.Annotation;
-//import org.eclipse.tracecompass.tmf.core.model.annotations.Annotation;

Also applies to: 58-59

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java`
around lines 29 - 30, In FlameChartDataProviderTest remove the commented-out
duplicate import statements for java.util.stream.Collectors (the commented line
above the active import and the duplicate at the later import block) so only the
single active import remains; locate the commented "//import
java.util.stream.Collectors;" entries near the top of the class and delete them
to clean up noise introduced during editing.

439-444: 💤 Low value

Dead-code branch in verifyStates after the new assertEquals.

Adding assertEquals(expectedStates.size(), states.size()) at line 439 is the right fix — it catches both under- and over-delivery of states. However, it makes lines 442–444 unreachable: the loop variable i is bounded by states.size(), which is now asserted equal to expectedStates.size(), so i > expectedStates.size() - 1 is always false. The fail(...) can never execute.

🧹 Proposed cleanup
     assertEquals(expectedStates.size(), states.size());
     for (int i = 0; i < states.size(); i++) {
         String entryName = entry.getName();
-        if (i > expectedStates.size() - 1) {
-            fail("Unexpected state at position " + i + FOR_ENTRY + entryName + ": " + states.get(i));
-        }
         ITimeGraphState actual = states.get(i);
         ITimeGraphState expected = expectedStates.get(i);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java`
around lines 439 - 444, The new assertEquals(expectedStates.size(),
states.size()) makes the conditional inside verifyStates' loop unreachable;
remove the dead branch that checks "if (i > expectedStates.size() - 1) {
fail(... entry.getName() ... states.get(i)) }" or replace the loop to iterate
over expectedStates.size() and directly compare elements, so the fail(...) call
and the unreachable i check are deleted; update verifyStates to perform direct
comparisons between expectedStates.get(i) and states.get(i) (using
entry.getName() only in failure messages).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java`:
- Around line 29-30: In FlameChartDataProviderTest remove the commented-out
duplicate import statements for java.util.stream.Collectors (the commented line
above the active import and the duplicate at the later import block) so only the
single active import remains; locate the commented "//import
java.util.stream.Collectors;" entries near the top of the class and delete them
to clean up noise introduced during editing.
- Around line 439-444: The new assertEquals(expectedStates.size(),
states.size()) makes the conditional inside verifyStates' loop unreachable;
remove the dead branch that checks "if (i > expectedStates.size() - 1) {
fail(... entry.getName() ... states.get(i)) }" or replace the loop to iterate
over expectedStates.size() and directly compare elements, so the fail(...) call
and the unreachable i check are deleted; update verifyStates to perform direct
comparisons between expectedStates.get(i) and states.get(i) (using
entry.getName() only in failure messages).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7a65ed87-2044-4802-bcab-72b639b00a43

📥 Commits

Reviewing files that changed from the base of the PR and between bdd20cc and 9a9e5c5.

📒 Files selected for processing (4)
  • analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/stubs/org/eclipse/tracecompass/analysis/profiling/core/tests/stubs2/KernelStateProviderStub.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented/FlameChartDataProvider.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented/FlameChartDataProvider.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant